package cn.daqisoft.util;

import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;

import java.util.Map;

/**
 *  创建握手接口拦截
 * @author 申浩
 *
 */
public class HandshakeInterceptor extends HttpSessionHandshakeInterceptor {
	 @Override  
	    public boolean beforeHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse response, WebSocketHandler wsHandler,
                                       Map<String, Object> map) throws Exception {  
	       
	        return super.beforeHandshake(serverHttpRequest, response, wsHandler, map);  
	    }  
	  
	    @Override  
	    public void afterHandshake(ServerHttpRequest request,
                                   ServerHttpResponse response, WebSocketHandler wsHandler,
                                   Exception ex) {  
	        System.out.println("After Handshake");  
	        System.out.println("结束拦截类");
	        super.afterHandshake(request, response, wsHandler, ex);  
	    }  
}
